package springboot.bigdata.demo.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import springboot.bigdata.demo.service.DataTransitionService;

@Controller
@RequestMapping("/dataTransition")
@Slf4j
@Api(description = "数据转换controller")
public class DataTransitionController {

    @Autowired
    private DataTransitionService dataTransitionService;

//    @ApiOperation("数据转换")
//    @ResponseBody
//    @GetMapping("/oldToNewDb")
//    public void oldToNewDb() throws InterruptedException {
//
//        CountDownLatch countDownLatch = new CountDownLatch(5);
//
//        Thread thread1 = new Thread(() -> {
//            dataTransitionService.staffToUser();
//            countDownLatch.countDown();
//        }, "thread1");
//        Thread thread2 = new Thread(() -> {
//            dataTransitionService.itemConfigToNewDb();
//            countDownLatch.countDown();
//        }, "thread2");
//        Thread thread3 = new Thread(() -> {
//            dataTransitionService.serviceItemToNewDb();
//            countDownLatch.countDown();
//        }, "thread3");
//        Thread thread4 = new Thread(() -> {
//            dataTransitionService.expenseToNewDb();
//            countDownLatch.countDown();
//        }, "thread4");
//        Thread thread5 = new Thread(() -> {
//            dataTransitionService.serviceLevenToNewDb();
//            countDownLatch.countDown();
//        }, "thread5");
//
//        thread1.start();
//        thread2.start();
//        thread3.start();
//        thread4.start();
//        thread5.start();
//
//        countDownLatch.await();
//        log.info("数据转换完毕======");
//        log.info("数据转换完毕======");
//        log.info("数据转换完毕======");
//        log.info("数据转换完毕======");
//        log.info("数据转换完毕======");
//    }
}
